/*
 * *
 *  * Created with IntelliJ RustRover.
 *  * Description:
 *  * Copyright Author: ZhenYi
 *  * DateTime: 2024/2/15 下午8:53
 *
 */

use salvo::prelude::*;
use crate::utensil::basic_local::LocalBasicAuth;

pub struct BasicAuthAdmin;
impl BasicAuthValidator for BasicAuthAdmin {
    async fn validate(&self, username: &str, password: &str, depot: &mut Depot) -> bool {
        let client = depot.obtain::<LocalBasicAuth>().unwrap();
        client.validate_auth_basic_admin(username, password).await
    }
}
pub struct BasicAuthAuthor;
impl BasicAuthValidator for BasicAuthAuthor {
    async fn validate(&self, username: &str, password: &str, depot: &mut Depot) -> bool {
        let client = depot.obtain::<LocalBasicAuth>().unwrap();
        client.validate_auth_basic_author(username, password).await
    }
}
pub struct BasicAuthExpert;
impl BasicAuthValidator for BasicAuthExpert {
    async fn validate(&self, username: &str, password: &str, depot: &mut Depot) -> bool {
        let client = depot.obtain::<LocalBasicAuth>().unwrap();
        client.validate_auth_basic_expert(username, password).await
    }
}